<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="template.xhtml">
	<ui:define name="content">
	
	<h1>Bentornato, <h:outputText value="#{sessionBean.name}" /></h1>
	
	<p:panel><center>
	<p>Mediante il form sottostante, puoi cercare il pacchetto viaggio ideale per le tue vacanze!</p>
	<h:form>
	<p:panelGrid columns="2">
		<f:facet name="header">  
        	Ricerca pacchetto viaggio  
    	</f:facet>
    	
    	
    	<h:outputLabel value="La tua destinazione:" />
    	<p:selectOneMenu value="#{packageSearchBean.searchParameters.locationId}" 
                         effect="fade" filter="true" filterMatchMode="contains">  
            <f:selectItem itemLabel="Qualsiasi destinazione" itemValue="0" />  
            <f:selectItems value="#{packageSearchBean.allLocations}" var="loc" itemLabel="#{loc.name} (#{loc.nation.name})" itemValue="#{loc.id}"/>  
  
        </p:selectOneMenu>
        
        <h:outputLabel value="Data di partenza:" />
        <p:calendar value="#{packageSearchBean.searchParameters.fromDate}" mindate="#{packageSearchBean.today}" editable="false" />
        
    	<f:facet name="footer"> 
    	
    		<center><p:commandButton value="Effettua ricerca" action="#{packageSearchBean.searchPackage}"></p:commandButton></center>
    	
    	</f:facet>
	
	</p:panelGrid>
	</h:form>
	</center></p:panel>
	<br />
	<h2>I pacchetti consigliati per te:</h2>
	<p:dataGrid var="pack" value="#{packageSearchBean.samplePackages}" columns="3"  
        rows="12">  
  
        <p:panel header="#{pack.name}" style="text-align:center">  
            <h:panelGrid columns="1" style="width:100%">  
            	<h:outputText value="#{pack.description}" />
            	<h4><h:outputText value="#{pack.extra}" /></h4><br />
            	<p:button outcome="packageDetails" value="Dettagli">  
				    <f:param name="packageId" value="#{pack.id}" />  
				</p:button>
            </h:panelGrid>  
        </p:panel>  
  
    </p:dataGrid> 

	</ui:define>
</ui:composition>
</html>